# -*- coding:utf-8 -*-
import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = 'y8)ahmo4#n)aoatj@en2r#f_u99l&b)%9z22+r--j7(+aq)w57'
DEBUG = True 
ALLOWED_HOSTS = ["*"]

INSTALLED_APPS = [
    'simpleui',
    #'adminlteui',
    'ckeditor',
    'rest_framework',
    'django_filters',
    'import_export',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'bedrockapp',
    'AppModel',
    'corsheaders',
    'mptt',
    'django_extensions',
    'werkzeug_debugger_runserver',
]

# env need pip install django-cors-headers

CORS_ORIGIN_ALLOW_ALL = True
# new
CORS_ALLOW_CREDENTIALS = True

#CORS_ALLOWED_ORIGINS = [
#    "https://brilliantlife.com.cn:8020/",
#    "https://brilliantlife.com.cn:8021/",
#    "http://localhost:8080",
#]


MIDDLEWARE = [
    #'django.middleware.cache.UpdateCacheMiddleware',
    "corsheaders.middleware.CorsMiddleware",
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    #'django.middleware.cache.FetchFromCacheMiddleware',
]

#CACHE_MIDDLEWARE_ALIAS = 'default'
#CACHE_MIDDLEWARE_SECONDS = 15*60
#CACHE_MIDDLEWARE_KEY_PREFIX = ''

ROOT_URLCONF = 'bedrockapp.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR+'/templates'],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'bedrockapp.wsgi.application'

#DATABASES = {
#    'default': {
#        'ENGINE': 'django.db.backends.sqlite3',
#        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
#        'OPTIONS': {
#            'timeout': 30,
#        }
#    }
#}


DATABASES = {
     'default': {
         'ENGINE': 'django.db.backends.mysql',
         'NAME': 'bedrock',
         'USER': 'bedrock',
         'PASSWORD': 'OStem@00',
         #'HOST': '114.115.177.137',
         'HOST': '192.168.0.74',
         'PORT': '60010',
#         'TEST': {
#             'CHARSET' : 'utf8',
#             'COLLATION':'utf8_general_ci'
#         }
     }
 }


#CACHES = {
#     'default': {
#     'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
#     'LOCATION': '127.0.0.1:11211',
#     }
#}


AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

LANGUAGE_CODE = 'zh-Hans'
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'

# simple ui setting
# 首页信息是否展示
SIMPLEUI_HOME_INFO = False
# 操作是否展示
SIMPLEUI_HOME_ACTION = True
# 数据分析是否展示
SIMPLEUI_ANALYSIS = False
# 快捷方式
SIMPLEUI_HOME_QUICK = True
# 批量导入数据
IMPORT_EXPORT_USE_TRANSACTIONS = True
#STATIC_ROOT = os.path.join(BASE_DIR, "/static/")
STATIC_ROOT = os.path.join(BASE_DIR, "cstatic/")
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'mstatic'),
)


SIMPLEUI_CONFIG = {
    'dynamic': True,
    'menus': [{
        'app': 'AppModel',
        'name': '泰达智慧群团',
        'icon': 'fab fa-dashcube',
        'models': [
         {
             'name': '公司管理',
             'url': 'AppModel/companyinfo',
             'icon': 'fa fa-server'
         },{
             'name': '员工管理',
             'url': 'AppModel/userinfo',
             'icon': 'fa fa-server'
         },{
             'name': '奖品管理',
             'url': 'AppModel/awardinfo',
             'icon': 'fa fa-server'
         },{
             'name': '题库管理',
             'url': 'AppModel/questionbank',
             'icon': 'fa fa-server'
         },{
             'name': '考卷管理',
             'url': 'AppModel/testpaperinfo',
             'icon': 'fa fa-server'
         },{
             'name': '成绩管理',
             'url': 'AppModel/examscore',
             'icon': 'fa fa-server'
         },{
             'name': '活动管理',
             'url': 'AppModel/actioninfo',
             'icon': 'fa fa-server'
         },{
             'name': '奖品领用',
             'url': 'AppModel/useraward',
             'icon': 'fa fa-server'
         },{
             'name': '抽奖管理',
             'url': 'AppModel/prizeinfo',
             'icon': 'fa fa-server'
         },{
             'name': '中奖信息',
             'url': 'AppModel/userprizeinfo',
             'icon': 'fa fa-server'
         },{
             'name': '用户登录管理',
             'url': 'AppModel/weixinapplogin',
             'icon': 'fa fa-server'
         }
        
        ]
        },{
        'app': 'auth',
        'name': '权限认证',
        'icon': 'fas fa-user-shield',
        'models': [{
            'name': '系统用户',
            'icon': 'fa fa-user',
            'url': 'auth/user/'
        },{
            'name': '用户组',
            'icon': 'fa fa-users',
            'url': 'auth/group/'
        }]
    }]
}

MPTT_ADMIN_LEVEL_INDENT = 20
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
PRCODE_ROOT = os.path.join(BASE_DIR, 'prcode')
PRCODE_URL = '/prcode/'
#SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
#SECURE_SSL_REDIRECT = True
#SESSION_COOKIE_SECURE = True
#CSRF_COOKIE_SECURE = True
CSRF_TRUSTED_ORIGINS = ['brilliantlife.com.cn']
#CSRF_TRUSTED_ORIGINS = ['*']
SESSION_COOKIE_SECURE = False
CSRF_COOKIE_SECURE = False
SECURE_SSL_REDIRECT = False
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'http')
CONF_DIR = os.path.join(BASE_DIR, "conf/bedrock.conf")
DATA_UPLOAD_MAX_NUMBER_FIELDS = 102400

DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

FILE_UPLOAD_MAX_MEMORY_SIZE = 8242880
